home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / cups.postinst < prev    next >
Encoding:
Text File  |  2008-10-20  |  6.1 KB  |  197 lines

  1. #! /bin/sh
  2. # postinst script for cups
  3. #
  4. # see: dh_installdeb(1)
  5.  
  6. set -e
  7.  
  8. # summary of how this script can be called:
  9. #        * <postinst> `configure' <most-recently-configured-version>
  10. #        * <old-postinst> `abort-upgrade' <new version>
  11. #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  12. #          <new-version>
  13. #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  14. #          <failed-install-package> <version> `removing'
  15. #          <conflicting-package> <version>
  16. # for details, see /usr/doc/packaging-manual/
  17. #
  18. # quoting from the policy:
  19. #     Any necessary prompting should almost always be confined to the
  20. #     post-installation script, and should be protected with a conditional
  21. #     so that unnecessary prompting doesn't happen if a package's
  22. #     installation fails and the `postinst' is called with `abort-upgrade',
  23. #     `abort-remove' or `abort-deconfigure'.
  24.  
  25. # Debconf
  26. . /usr/share/debconf/confmodule
  27.  
  28. # Default Configuration file
  29. if [ -e /etc/default/cups ]; then
  30.     . /etc/default/cups
  31. fi
  32.  
  33. case "$1" in
  34.     configure)
  35.     # Set up lpadmin group.
  36.     if [ -z "`getent group lpadmin`" ]; then 
  37.         addgroup --system lpadmin
  38.     fi
  39.  
  40.     if [ -L /usr/share/ppd/cups-transitional-dir ]; then
  41.         rm -f /usr/share/ppd/cups-transitional-dir
  42.     fi
  43.     if [ -L /usr/share/cups/model/cups-included ]; then
  44.         rm -f /usr/share/cups/model/cups-included
  45.     fi
  46.  
  47.     # Generate raw MIME handling files if they don't already exist.
  48.     if [ ! -e /etc/cups/raw.types ]; then
  49.         cat >/etc/cups/raw.types <<EOF
  50. # This file was generated by the cups package.  You may change it, or
  51. # reconfigure this file with dpkg-reconfigure.  If it is removed, it
  52. # will be regenerated by the package scripts.
  53.  
  54. application/octet-stream
  55. EOF
  56.     fi
  57.     if [ ! -e /etc/cups/raw.convs ]; then
  58.         cat >/etc/cups/raw.convs <<EOF
  59. # This file was generated by the cups package.  You may change it, or
  60. # reconfigure this file with dpkg-reconfigure.  If it is removed, it
  61. # will be regenerated by the package scripts.
  62.  
  63. application/octet-stream    application/vnd.cups-raw    0    -
  64. EOF
  65.     fi
  66.  
  67.     # Set up raw printing of application/octet-stream if desired.
  68.     db_fget cupsys/raw-print changed
  69.     if [ "$RET" = "true" ]; then
  70.         mv /etc/cups/raw.convs /etc/cups/raw.convs-convert
  71.         db_get cupsys/raw-print
  72.         if [ "$RET" = "true" ]; then
  73.         sed 's/^\s*#\s*application/application/' \
  74.             < /etc/cups/raw.convs-convert > /etc/cups/raw.convs
  75.         else
  76.         sed 's/^application/#application/' \
  77.             < /etc/cups/raw.convs-convert > /etc/cups/raw.convs
  78.         fi
  79.         rm -f /etc/cups/raw.convs-convert
  80.         db_fset cupsys/raw-print changed false
  81.     fi
  82.     # Set up backends
  83.     db_get cupsys/backend && SELECTED=$RET
  84.     list=`echo $SELECTED | sed -e 's/, /,/g'`
  85.     save_IFS=$IFS
  86.     IFS=,
  87.     (cd /usr/lib/cups/backend && rm -f http ipp lpd parallel scsi serial socket usb snmp dnssd)
  88.     for module in $list; do
  89.       ln /usr/lib/cups/backend-available/$module /usr/lib/cups/backend/$module
  90.       if [ "$module" = "ipp" ]; then
  91.             ln /usr/lib/cups/backend/ipp /usr/lib/cups/backend/http
  92.       fi
  93.     done
  94.     IFS=$save_IFS
  95.  
  96.     # activate new backends on upgrades
  97.     db_fset cupsys/backend changed false
  98.     
  99.     if dpkg --compare-versions "$2" lt-nl "1.3.4-2"; then
  100.         for module in snmp scsi serial dnssd; do
  101.             [ -e /usr/lib/cups/backend/$module ] || \
  102.             ln /usr/lib/cups/backend-available/$module /usr/lib/cups/backend/$module
  103.         done
  104.     fi
  105.     
  106.     # Resync Debconf database with real state
  107.     list=`( cd /usr/lib/cups/backend && for f in ipp lpd parallel scsi serial socket usb snmp dnssd; do [ -e $f ] && echo -n "$f, "; done ) | sed -e 's/, $//'`
  108.     db_set cupsys/backend $list;
  109.  
  110.     if [ -f /etc/cups/classes.conf ]; then
  111.       chown root:lp /etc/cups/classes.conf ; chmod 600 /etc/cups/classes.conf
  112.     fi
  113.     if [ -f /etc/cups/printers.conf ]; then
  114.       chown root:lp /etc/cups/printers.conf ; chmod 600 /etc/cups/printers.conf
  115.     fi
  116.     # Add symlink to local files required by LSB
  117.     if [ ! -e /usr/share/ppd/1-local-admin -a ! -L /usr/share/ppd/1-local-admin ]; then
  118.       ln -s /usr/local/share/ppd /usr/share/ppd/1-local-admin
  119.     fi
  120.     if [ ! -e /usr/share/ppd/2-third-party -a ! -L /usr/share/ppd/2-third-party ]; then
  121.       ln -s /opt/share/ppd /usr/share/ppd/2-third-party
  122.     fi
  123.  
  124.         # symlink snakeoil SSL certificate if present
  125.         if [ -e /etc/ssl/certs/ssl-cert-snakeoil.pem -a \
  126.               -e /etc/ssl/private/ssl-cert-snakeoil.key -a \
  127.               -n "`getent group ssl-cert`" -a ! -e /etc/cups/ssl/server.crt -a \
  128.               ! -e /etc/cups/ssl/server.key ]; then
  129.              ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/cups/ssl/server.crt
  130.              ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/cups/ssl/server.key
  131.         fi 
  132.  
  133.         # Remove shutdown and reboot links; this init script does not need them.
  134.         if dpkg --compare-versions "$2" lt-nl "1.3.6-2"; then
  135.             rm -f /etc/rc0.d/K??cups /etc/rc6.d/K??cups
  136.         fi
  137.  
  138.         # Reload AppArmor profile if present
  139.         if [ -e /etc/apparmor.d/usr.sbin.cupsd ] && [ -x /etc/init.d/apparmor ]; then
  140.             invoke-rc.d apparmor force-reload || true
  141.         fi
  142.     ;;
  143.  
  144.     abort-upgrade|abort-remove|abort-deconfigure)
  145.  
  146.     ;;
  147.  
  148.     *)
  149.         echo "postinst called with unknown argument \`$1'" >&2
  150.         exit 0
  151.     ;;
  152. esac
  153.  
  154. # dh_installdeb will replace this with shell code automatically
  155. # generated by other debhelper scripts.
  156.  
  157. # Automatically added by dh_installdocs
  158. if [ "$1" = configure ] && which install-docs >/dev/null 2>&1; then
  159.     install-docs -i /usr/share/doc-base/cups
  160. fi
  161. # End automatically added section
  162. # Automatically added by dh_installinit
  163. if [ -x "/etc/init.d/cups" ]; then
  164.     update-rc.d cups start 20 2 3 4 5 . stop 80 1 . >/dev/null
  165.     if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  166.         invoke-rc.d cups start || exit $?
  167.     else
  168.         /etc/init.d/cups start || exit $?
  169.     fi
  170. fi
  171. # End automatically added section
  172. # Automatically added by dh_usrlocal
  173. if [ "$1" = configure ]; then
  174. (
  175.     while read line; do
  176.         set -- $line
  177.         dir="$1"; mode="$2"; user="$3"; group="$4"
  178.         if [ ! -e "$dir" ]; then
  179.             if mkdir "$dir" 2>/dev/null; then
  180.                 chown "$user":"$group" "$dir"
  181.                 chmod "$mode" "$dir"
  182.             fi
  183.         fi
  184.     done
  185. ) << DATA
  186. /usr/local/share 2775 root staff
  187. /usr/local/share/ppd 2775 root staff
  188. DATA
  189. fi
  190. # End automatically added section
  191.  
  192.  
  193. db_stop
  194. exit 0
  195.  
  196.  
  197.